package com.example.importDemo.config;

import org.springframework.stereotype.Component;

import javax.servlet.*;
import java.io.*;
import java.nio.file.Files;
import java.util.Date;

//@Component
public class MyFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
//        Filter.super.init(filterConfig);
        System.out.println("--------------------------kaishi");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

    }

    @Override
    public void destroy() {
//        Filter.super.destroy();
        System.out.println("--------------------------处理了些数据");

        String sourcePath = "C:/Users/wangkl/Desktop/文档/RTI.docx";
        String destPath = "C:/Users/wangkl/Desktop/文档/test/RTI_" + new Date().getTime() + ".docx";
        File source = new File(sourcePath);
        File dest = new File(destPath);
        try {
            Files.copy(source.toPath(), dest.toPath());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        System.out.println("--------------------------jieshu");
    }
}
